0.1 Datos

Descarga la base de datos del bosque silverwoods:

0.1.1 Librerias

Carga las librerias necesarias y ejecuta los comandos que describen los datos:

library(ggplot2)
library(plotly)
# setwd("~/parcial1")

0.1.2 Nombres de las variables

names(clima)
## [1] "upper" "lower" "rain"  "month" "yr"
attach(clima)
head(clima)
str(clima)
## 'data.frame':    6940 obs. of  5 variables:
##  $ upper: num  10.8 10.5 7.5 6.5 10 8 5.8 2.8 -0.8 1.5 ...
##  $ lower: num  6.5 4.5 -1 -3.3 5 3 -3.3 -5.5 -4.8 -1 ...
##  $ rain : num  12.2 1.3 0.1 1.1 3.5 0.1 0 0 0 0 ...
##  $ month: int  1 1 1 1 1 1 1 1 1 1 ...
##  $ yr   : int  1987 1987 1987 1987 1987 1987 1987 1987 1987 1987 ...

0.1.3 Cambio a FACTOR

month<-factor(month)
attach(clima)
str(clima)
## 'data.frame':    6940 obs. of  5 variables:
##  $ upper: num  10.8 10.5 7.5 6.5 10 8 5.8 2.8 -0.8 1.5 ...
##  $ lower: num  6.5 4.5 -1 -3.3 5 3 -3.3 -5.5 -4.8 -1 ...
##  $ rain : num  12.2 1.3 0.1 1.1 3.5 0.1 0 0 0 0 ...
##  $ month: int  1 1 1 1 1 1 1 1 1 1 ...
##  $ yr   : int  1987 1987 1987 1987 1987 1987 1987 1987 1987 1987 ...
is.factor(month)
## [1] TRUE

0.2 Preg1

Como es el clima en cada mes para los años 1987-2005 en el bosque silverwoods (temp maximas)
Que mes

#plot(month,upper)
q1 <- ggplot(clima, aes(month, upper, fill=factor(month) ))
q1 <- q1 + geom_boxplot() + xlab("") + theme(legend.position = "none")
ggplotly(q1)

0.3 Preg 2 - Analisis de solo Enero para el Año 2000

enero <- subset(clima, yr == 2000 )
head(enero)
enero <- subset(enero, month == 1 )
tail(enero)

0.3.1 Grafica del mes de Enero

qenero <- ggplot(enero, aes(month, upper, fill=factor(month) ))
qenero <- qenero + geom_boxplot() + xlab("") + theme(legend.position = "none")
ggplotly(qenero)

0.3.2 Preg 3 Analisis de solo Marzo en lower para todos los años

clima2 <- subset(clima, month =="3")
attach(clima2)
yr<-factor(yr)
head(clima2)
q2 <- ggplot(clima2, aes(yr, lower , fill=factor(yr) ))
q2 <- q2 + geom_boxplot() + xlab("") + theme(legend.position = "none")
ggplotly(q2)

0.4 Sacamos la mediana y la graficamos

(med <- median(clima2$lower))
## [1] 3.3

0.5 Grafica Temperatura media Baja para el mes 3

(q3 <- q2 + geom_hline(aes(yintercept=med), color= 2))

quantile(clima2$lower)
##   0%  25%  50%  75% 100% 
## -7.3  0.5  3.3  6.0 12.0
(pp <- ggplot(clima2, aes(month,lower, fill="red")) + geom_boxplot())

ggplotly(pp)
quantile(clima2$lower)#SOLO PARA EL MES 3
##   0%  25%  50%  75% 100% 
## -7.3  0.5  3.3  6.0 12.0
d <- ggplot(clima2, aes(clima2$lower)) + geom_density(fill="slateblue")
d
## Warning: Use of `clima2$lower` is discouraged. Use `lower` instead.